package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.game.activity.thirtyday.ThirtyDayShopTemplate;

import gnu.trove.map.hash.TIntObjectHashMap;
import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class ThirtyDayShopListResponse extends Response {

	private List<ThirtyDayShopItem> dayList;
	private List<ThirtyDayShopItem> weekList;
	public static class ThirtyDayShopItem{
		public int itemId;
		public int itemCount;
		public int costBond;
		public int costStone;
		public int leftCount;
		public int limitCount;
		public int discount;
		public ThirtyDayShopItem(ThirtyDayShopTemplate temp, int count){
			this.itemId = temp.getId();
			this.itemCount = temp.getCount();
			this.costBond = temp.getCostBond();
			this.costStone = temp.getCostStone();
			this.limitCount = temp.getLimitCount();
			this.leftCount = this.limitCount - count;
			if(this.leftCount < 0){
				this.leftCount = 0;
			}
			this.discount = temp.getShowDiscount();
		}
	}
	public ThirtyDayShopListResponse(int serial, TIntObjectHashMap<Integer> item2count, List<ThirtyDayShopTemplate> shopTempList) {
		super(serial);
		int size = shopTempList.size();
		dayList = new ArrayList<ThirtyDayShopItem>();
		weekList = new ArrayList<ThirtyDayShopItem>();
		for (int i = 0; i < size; i++) {
			ThirtyDayShopTemplate temp = shopTempList.get(i);
			int count = 0;
			if(item2count.contains(temp.getId())){
				count = item2count.get(temp.getId());
			}
			ThirtyDayShopItem item = new ThirtyDayShopItem(temp, count);
			if(temp.getType() == 0){
				dayList.add(item);
			}else if(temp.getType() == 1){
				weekList.add(item);
			}
		}
	}
	public List<ThirtyDayShopItem> getDayList() {
		return dayList;
	}
	public void setDayList(List<ThirtyDayShopItem> dayList) {
		this.dayList = dayList;
	}
	public List<ThirtyDayShopItem> getWeekList() {
		return weekList;
	}
	public void setWeekList(List<ThirtyDayShopItem> weekList) {
		this.weekList = weekList;
	}
}
